padding: 4,
corner_radius: WELL_MENU_CORNER_RADIUS,
width: Main.overview._dash.actor.width * 0.75 });
- this._windowContainer.connect('popdown', Lang.bind(this, this._onPopdown));
this._windowContainer.connect('unselected', Lang.bind(this, this._onWindowUnselected));
this._windowContainer.connect('selected', Lang.bind(this, this._onWindowSelected));
+ this._windowContainer.connect('cancelled', Lang.bind(this, this._onWindowSelectionCancelled));
this._windowContainer.connect('activate', Lang.bind(this, this._onWindowActivate));
this.actor.add_actor(this._windowContainer);
_onWindowActivate: function (actor, child) {
let window = child._window;
Main.overview.activateWindow(window, Clutter.get_current_event_time());
+ this.emit('popup', false);
+ this.actor.hide();
},
- _onPopdown: function () {
+ _onWindowSelectionCancelled: function () {
this.emit('highlight-window', null);
this.emit('popup', false);
this.actor.hide();
G_DEFINE_TYPE(ShellMenu, shell_menu, BIG_TYPE_BOX);
struct _ShellMenuPrivate {
+ gboolean popped_up;
gboolean have_grab;
ClutterActor *selected;
UNSELECTED,
SELECTED,
ACTIVATE,
- POPDOWN,
+ CANCELLED,
LAST_SIGNAL
};
return actor != NULL;
}
+static void
+shell_menu_popdown_nosignal (ShellMenu *box)
+{
+ box->priv->popped_up = FALSE;
+ if (box->priv->have_grab)
+ clutter_ungrab_pointer ();
+ clutter_actor_hide (CLUTTER_ACTOR (box));
+}
+
static void
on_selected_destroy (ClutterActor *actor,
ShellMenu *box)
if (event->button != 1)
return FALSE;
- shell_menu_popdown (box);
+ shell_menu_popdown_nosignal (box);
- if (!shell_menu_contains (box, event->source))
- return FALSE;
+ if (!shell_menu_contains (CLUTTER_CONTAINER (box), event->source))
+ {
+ g_signal_emit (G_OBJECT (box), shell_menu_signals[CANCELLED], 0);
+ return FALSE;
+ }
if (box->priv->selected == NULL)
- return FALSE;
+ {
+ g_signal_emit (G_OBJECT (box), shell_menu_signals[CANCELLED], 0);
+ return FALSE;
+ }
g_signal_emit (G_OBJECT (box), shell_menu_signals[ACTIVATE], 0, box->priv->selected);
guint button,
guint32 activate_time)
{
+ if (box->priv->popped_up)
+ return;
+ box->priv->popped_up = TRUE;
box->priv->have_grab = TRUE;
clutter_grab_pointer (CLUTTER_ACTOR (box));
}
+/**
+ * shell_menu_popdown:
+ * @box:
+ *
+ * If the menu is currently active, hide it, emitting the 'cancelled' signal.
+ */
void
shell_menu_popdown (ShellMenu *box)
{
- if (box->priv->have_grab)
- clutter_ungrab_pointer ();
- clutter_actor_hide (CLUTTER_ACTOR (box));
- g_signal_emit (G_OBJECT (box), shell_menu_signals[POPDOWN], 0);
+ if (!box->priv->popped_up)
+ return;
+ shell_menu_popdown_nosignal (box);
+ g_signal_emit (G_OBJECT (box), shell_menu_signals[CANCELLED], 0);
}
/**
G_TYPE_NONE, 1, CLUTTER_TYPE_ACTOR);
/**
- * ShellMenu::popdown
+ * ShellMenu::cancelled
* @box: The #ShellMenu
*
- * This signal is emitted when the menu is removed from the display.
+ * This signal is emitted when the menu is closed without an option selected.
*/
- shell_menu_signals[POPDOWN] =
- g_signal_new ("popdown",
+ shell_menu_signals[CANCELLED] =
+ g_signal_new ("cancelled",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,